<template>
	<view style="background: #AEE2DA;min-height: 100vh;" class="Afont"
		:style="{background:'url('+Imgbase+'/new_goodday_bgc4.png)','background-size':'100%',}">
		<view class="padding-top-50 padding-left-40">
			<image class="w-80 h-80" :src="Imgbase + '/new_goodlx_img1.png'" mode="aspectFit" @click="back">
			</image>
		</view>
		<!-- :style="[{height:TabCur==0?'320rpx':'0rpx'}]" -->
		<view class="padding-top-310 overhid flex Afont margin-auto flex-center font-40">
			<view class="padding-right-20">
				已签到
			</view>
			<view
				class="scoity-center-day radius-22 text-center padding-left-35 padding-right-35 padding-bottom-10 font-70">
				{{day}}
			</view>
			<view class=" padding-left-20">
				天
			</view>
		</view>

		<!-- 立即签到 -->
		<view class="text-center padding-top-140">
			<image @click="postSign()" class="w-285 h-80" :src="Imgbase + '/new_goodday_img1.png'" mode="aspectFit"
				v-if="res == 0">
			</image>

			<image @click="postSign()" class="w-285 h-80" :src="Imgbase + '/new_goodday_img1n.png'" mode="aspectFit"
				v-else>
			</image>
		</view>

		<view class="padding-top-300">

			<scroll-view scroll-y class="w100 h-340" scroll-with-animation style="overflow: hidden;"
				@scrolltolower="onbottom()">

				<view class="h-200 padding-top-50 w-570 margin-auto margin-top-25 padding-left-30 padding-right-30"
					v-for="(item,index) in userlist" :key="index"
					:style="{background:'url('+Imgbase+'/app_sign_c_middle2.png)','background-size':'100% 100%',}">
					<view class="text-sm" style="padding-left: 20upx;padding-right: 20upx;color: #5c4228;">
						<view class="content fl text-ablack text-df">
							{{item.memo}}
						</view>
						<view class="action fr text-df" style="color: #3AB54A;">
							+{{item.money}}
						</view>
					</view>
					<view style="clear: both;"></view>
					<view class="text-sm font-22 padding-left-20 padding-top-15" style="color: #5c4228;">
						<view class="content  text-ablack ">
							获得时间: {{item.create_at}}
						</view>
						<view class="action  text-ablack padding-top-8">
							<!-- 到期时间: {{item.end_at}} -->
						</view>
					</view>
				</view>

			</scroll-view>
		</view>

		<!-- 恭喜获得 -->
		<view class="cu-modal" :class="modalName=='buyModal'?'show':''" @tap="hideModal" @tap.stop="">
			<view class="cu-dialog" style="background-color:initial;margin-top: 100rpx;width: 90%;height: 70%;"
				:style="{background:'url('+Imgbase+'/new1_infinite_boxtanchuangbgc.png) no-repeat','background-size':'100% 100%'}">

				<view class="padding-top-250 padding-left-70 padding-right-100 overhid h-900">

					<view class="fl margin-right-25 margin-bottom-20" v-for="(item,index) in list" :key="index">
						<view class="w-150 h-150" style="position: relative;">
							<image class="w100 h100 radius-15" :src="item.image" mode="aspectFill"></image>

							<view class="bynum" v-if="item.num > 1">
								x{{item.num}}
							</view>
						</view>

						<view class="font-26 padding-top-8">
							{{item.title}}
						</view>
					</view>
				</view>

				<view class="w-250 margin-auto">
					<u-button text="确定" color="#F38948"></u-button>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				Imgbase: getApp().globalData.Imgbase,
				day: 0,
				issigned: 0,
				scoreData: true,
				scorelist: [],
				scorepage: 1,
				scorecount: 0,
				mes: '',
				modalName: '',
				scroll: 0,
				list: [],
				userlist: [],
				page: 1,
				res: -1
			};
		},
		onShow() {
			this.isSign()
		},
		methods: {
			// 优惠券分页
			onbottom() {
				this.page++
				this.expIconLog()
			},
			// 查看优惠券
			async expIconLog() {
				let _this = this;
				let item = await this.$api.post('userways/expIconLog', {
					token: uni.getStorageSync('token'),
					type: 3,
					page: this.page,
					// limit: 2
				})
				_this.userlist = _this.userlist.concat(item.data.list)

			},
			// 检测签到
			async isSign() {
				let _this = this;
				let item = await this.$api.post('usersys/isSign', {
					token: uni.getStorageSync('token'),
				})
				_this.res = item.data.res
				_this.day = item.data.count

				this.expIconLog()

			},
			// 签到
			async postSign() {
				let _this = this;
				let item = await this.$api.post('usersys/postSign', {
					token: uni.getStorageSync('token'),
				})

				if (item.code == 1) {
					// 判断签到有无奖励
					if (item.data.list.length > 0) {
						this.list = item.data.list
						this.modalName = 'buyModal'
						this.page = 1
						_this.userlist = []
						this.expIconLog()
					} else {
						uni.showToast({
							icon: 'none',
							title: item.msg
						});
					}

					_this.isSign()
				}
			},
			back() {
				uni.navigateBack()
			},
			hideModal(e) {
				this.modalName = null
			},
		}

	}
</script>
<style lang="less" scoped>
	.bynum {
		position: absolute;
		top: 8rpx;
		right: 8rpx;
	}

	.jiitem {
		float: left;
		margin-right: 20rpx;
		margin-bottom: 22rpx;
		position: relative;

		.opc {
			position: absolute;
			z-index: 10;
			background-color: rgba(0, 0, 0, .4);
			top: 2.5%;
			left: 2.5%;
			width: 95%;
			height: 95%;
		}

		.opc1 {
			position: absolute;
			z-index: 10;
			background-color: rgba(0, 0, 0, .4);
			top: 2.5%;
			left: 2%;
			width: 96%;
			height: 95%;
		}

		.zin {
			position: relative;
			z-index: 11;
		}
	}

	.jiitem:nth-child(4) {
		margin-right: 0;
	}

	.jiitem:nth-child(7) {
		margin-right: 0;
	}

	.scoity-center-day {
		color: #f9a24b;
		background-color: rgba(255, 255, 255, .8);
	}

	.scoity-center-qiandao {
		margin-top: 60rpx;
	}

	.scoity-center-qiandao-text {
		font-size: 32rpx;
		text-decoration: underline;
		color: #FFFFFF;
		text-align: center;

	}
</style>